package com.ctshk.rpc.scenic.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.scenic.entity.ScenicProductCostStrategySpecAttr;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 成本策略价格规格属性 Mapper 接口
 * </p>
 *
 * @author wangcy
 * @since 2021-02-02
 */
public interface ScenicProductCostStrategySpecAttrMapper extends BaseMapper<ScenicProductCostStrategySpecAttr> {
    /**
     * 批量删除
     * @param productId
     * @param
     * @return
     */
    @Update("delete * from  t_scenic_product_cost_strategy_spec_attr \n" +
            "WHERE   product_id = #{product_id}")
    Integer batchDel(@Param("product_id") Long productId);

    @Update("update t_scenic_product_cost_strategy_spec_stock" +
            " set surplus_stock=surplus_stock -${number} ,sold_stock=sold_stock+${number} " +
            "where id =#{stockId} ")
    Integer updateStock(Long stockId, Integer number);
    @Update("update t_scenic_product_cost_strategy_spec_stock" +
            " set surplus_stock=surplus_stock +${number} ,sold_stock=sold_stock-${number} " +
            "where id =#{stockId} ")
    Integer updateAddStock(Long stockId, Integer number);

}
